﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceProcess;
using System.Text;
using BitAuto.EP.CRMLogSystem.Utils;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json;
using System.Threading.Tasks;
using BitAuto.EP.CRMLogSystem.Entity;
using System.Web.Script.Serialization;
using System.IO;
namespace CRMSimple.LogServices
{
    static class Program
    {
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        static void Main()
        {
            ServiceBase[] ServicesToRun;
            ServicesToRun = new ServiceBase[] 
            { 
                new LogService() 
            };
            //ServiceBase.Run(ServicesToRun);
            #region config
            //ConfigurationManager config = new ConfigurationManager();

            #endregion
            #region produterTest
            //LogServiceContextRoot producter = new LogServiceContextRoot()
            //                  .UseRMQProducter()
            //                  .UseTextFileDataCache()
            //                  .Buid();
            ////Task.Factory.StartNew(producter.RunTest);
            //var task=producter.Run;
            //task.Start();
            //task.Wait();

            //task.ContinueWith(e => {
            //    var ex = e.Exception;
            //});
            //task.Exception;
            //var s = task.Status;
            //Singleton<ConfigurationManager>.Instance;
            #endregion
            //var Json = JsonConvert.DeserializeObject("{\"ConsumeCount\":\"500\"\"CurrentCount\":\"0\"\"CreateFileCount\":\"0\"\"ReadFileName\":\"\"\"WriteFileName\":\"\"\"ErrorFiles\":\"[]\"}") as JObject;
            #region consumerTest
            //LogServiceContextRoot consumer = new LogServiceContextRoot()
            //                    .UseRMQProducter()
            //                    .UseRMQConsumer()
            //                    .UseTextFileDataCache()
            //                    .Buid();
            //consumer.RunTest();
            //new DeleteFileProcess().Run(null);
            //task.Start();
            //task.Wait();
            #endregion
            #region deleteFileTest
            //var task = new DeleteFileProcess().Run;
            //task.Start();
            //task.Wait(); 
            #endregion

            #region JavaScriptSerializerTest
            //ProduceDataForMQ proInfo = JsonHelper.Deserialize<ProduceDataForMQ>("{\"Data\":\"{\"LogTableId\":2,\"LogContent\":\"客户ID：4904.通过PC端口进行了购车意向跟进操作，包含订单1条，订单ID:196081512,话单0条，话单ID:\"}\",\"PushTime\":\"2017-01-11T19:10:13.0388823\"}"); 
            #endregion



        }
    }
}
